# Empty list
SET(TINES_EXAMPLE_SOURCES "")

# Append examples that work for all device types
LIST(APPEND TINES_EXAMPLE_SOURCES
  Tines_NumericalJacobian.cpp
  Tines_AnalyticJacobian.cpp
  Tines_NewtonSolver.cpp
  Tines_TrBDF2.cpp
  Tines_TimeIntegratorTrBDF2.cpp
)

#
# Create examples for the above sources
#
FOREACH(TINES_EXAMPLE_SOURCE ${TINES_EXAMPLE_SOURCES} )
  STRING( REPLACE ".cpp" ".single.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
  ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
  SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_SINGLE_PRECISION")
  TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
  INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
          PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
          DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")

  STRING( REPLACE ".cpp" ".double.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
  ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
  SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_DOUBLE_PRECISION")
  TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
  INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
          PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
          DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")
ENDFOREACH()

#
# CVODE example runs with predefined real type i.e., double
#
IF (TINES_ENABLE_TPL_SUNDIALS)
  SET(TINES_EXAMPLE_EXE Tines_TimeIntegrator.double.x)
  SET(TINES_EXAMPLE_SOURCE Tines_TimeIntegratorCVODE.cpp)
  STRING( REPLACE ".cpp" ".double.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
  ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
  SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_DOUBLE_PRECISION")
  TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
  INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
          PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
          DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")
ENDIF()

